package com.anrongtec.zcpt.manager;

import java.util.HashMap;
import java.util.Map;

import android.content.Context;
import android.view.View;

import com.anrongtec.zcpt.view.BadgeView;

/**
 * 提示的红点 管理类
 * @author cxy
 *
 */
public class BadgeViewManager {
	
	public BadgeView badge;
	
	/**
	 * badgemap
	 */
	private Map<View, BadgeView> badgeMap = new HashMap<View, BadgeView>();
	
	public static BadgeViewManager instance;
	
	private Context context;
	
	public synchronized static BadgeViewManager getInstance(Context context){
		
		if (instance == null) {
			instance = new BadgeViewManager();
		}
		instance.context = context;
		return instance;
	}
	
	public void setBadge(View view){
		setBadge(view, 0);
	}
	
	public void setBadge(View view, int count){
		badge = badgeMap.get(view);
		if (badge == null) {
			badge = new BadgeView(context);
			badge.setTargetView(view);
			badgeMap.put(view, badge);
		}
		badge.setBadgeCount(count);
	}
	
	public BadgeView getBadgeView(View view){
		return badgeMap.get(view);
	}
	
}
